import React, { Component } from 'react'
import { Text, StyleSheet, View } from 'react-native'
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack';
import { Provider } from 'react-redux'
import store from './redux/store'

import BottomTabs from './routes'
import LoginScreen from './screens/Profile/Login'
import RegisterScreen from './screens/Profile/Register'
import CounterScreen from './screens/Profile/Counter'
import HomeScreen from './screens/Home'

const Stack = createStackNavigator();

export default class index extends Component {
  constructor(props) {
    super(props)

    // this.state(
      
    // )
  }
  componentDidMount() {
    console.log('store', store.getState())
  }

  shouldComponentUpdate(nextProps, nextState) {
    // console.log('nextProps111', nextProps)
    // console.log('nextState111', nextState)

    // // 判断是否更新组件
    // if (this.props.num !== nextProps.num) {
    //   return true;
    // }
    // return false;
  }
  
  render() {
    
    return (
      <Provider store={store}>
        <NavigationContainer>
          <Stack.Navigator
            // headerMode={'none'}
            // initialRouteName="Login"
          >
          {store.getState().User.isLogin ? (
            // 用户已登录
            <Stack.Screen 
              name="BottomTabs" 
              component={BottomTabs} 
              options={{
                headerShown: false,
              }}
            />
          ) : (
            <>
              <Stack.Screen name="Login" component={LoginScreen} />
              <Stack.Screen name="Register" component={RegisterScreen} />
              <Stack.Screen name="Counter" component={CounterScreen} />
            </>
          )}
          </Stack.Navigator>
        </NavigationContainer>
      </Provider>
    )
  }
}

const styles = StyleSheet.create({})
